package User;


import java.util.Scanner;

public class Adm_User_View {
    // 显示操作菜单
    public static void displayMenu() {
        System.out.println("\n=========================================");
        System.out.println("            用户信息管理");
        System.out.println("=========================================");
        System.out.println("请选择操作：");
        System.out.println("1. 删除");
        System.out.println("2. 查询");
        System.out.println("3. 返回");
        System.out.println("=========================================");
    }


    public static void User() throws Exception {
        Scanner scanner = new Scanner(System.in);
        boolean running = true;

        while (running) {

            displayMenu();

            System.out.print("请输入您的选择: ");
            int choice = scanner.nextInt();

            scanner.nextLine();
            UserDAO user = new User();
            switch (choice) {
                case 1:
                    System.out.println("\n=========================================");
                    System.out.println("            删除用户信息");
                    System.out.println("=========================================");
                    user.getUser();
                    System.out.println("请输入要删除的账户名：");
                    String name = scanner.nextLine();
                    user.deleteUser(name);
                    break;
                case 2:
                    System.out.println("\n=========================================");
                    System.out.println("            查询全部用户信息");
                    System.out.println("=========================================");
                    user.getUser();
                    break;
                case 3:
                    // 选择退出到主界面
                    System.out.println("\n=========================================");
                    System.out.println("正在返回主界面...");
                    System.out.println("=========================================");
                    running = false;
                    break;
                default:
                    System.out.println("\n输入无效，请重新选择！");
                    break;
            }

        }
    }
}
